<?php
// +---------------------------------------------------------------
// | Tommy Framework 开发辅助工具
// +---------------------------------------------------------------
// | Copyright (c) 2009 http://www.tommycode.com All rights reserved.
// +---------------------------------------------------------------
// | Author: streen003 <streen003gmail.com>
// +---------------------------------------------------------------

//获取mode信息.
if(htmlspecialchars(trim($_GET['mode']))=='login'){

	$user = htmlspecialchars(trim($_POST['user']));
	$password = htmlspecialchars(trim($_POST['password']));

	include 'config.php';

	if($user==$user_name&&$password==$user_password){

		setcookie('tommy_tools_login', true, time()+1200);
	}
	
	header('LOCATION:index.php');
	exit;
}
else{
	
	if($_COOKIE['tommy_tools_login']==false){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<style type="text/css">
<!--
body{margin-left:0px; margin-top:0px; font-family:Arial,Helvetica,sans-serif; font-size:14px; color:#000; text-align:center}
.login_from{padding:0px; height:284px; width:404px; margin-top:150px; margin-right:auto; margin-bottom:0px; margin-left:auto; text-align:left; border:1px solid #C3D9FF}
.login_box{height:280px; width:400px; padding:0px; font-size:14px; background-color:#E8EEFA; margin:2px; border-top-style:none; border-right-style:none; border-bottom-style:none; border-left-style:none}
.login_from .login_box tr .menu{font-size:18px; font-weight:bold; line-height:70px; color:#C00; text-align:center}
.login_from .login_box .input{font-size:14px; line-height:24px; height:24px; width:200px; border:1px solid #C3D9FF}
-->
</style>
</head>
<body>
<div class="login_from">
<table width="400" border="0" cellspacing="0" cellpadding="0" class="login_box">
<form action="index.php?mode=login" method="post" id="login">
  <tr>
    <td height="70" colspan="3" class="menu">登 陆</td>
    </tr>
  <tr>
    <td width="100" height="70" align="right">用户：</td>
    <td width="20">&nbsp;</td>
    <td width="280"><input type="text" name="user" class="input"/></td>
  </tr>
  <tr>
    <td width="100" height="70" align="right">密码：</td>
    <td width="20">&nbsp;</td>
    <td width="280"><input type="password" name="password" class="input"/></td>
  </tr>
  <tr>
    <td height="70" colspan="3" align="center"><input type="submit" name="submit" value="提交" />&nbsp;&nbsp;<input type="reset" name="reset" value="重值" /></td>
    </tr>
</form>   
</table>
</div>
</body>
</html>
<?php
		exit;
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tommy Framework Tools</title>
<script type="text/javascript" src="ajax/jquery.min.js"></script>
<script type="text/javascript">
$(function(){select_menu='menu_001';$('#'+select_menu).addClass('selected');$('#'+select_menu+'_content').show();$('#menu_001').bind('mouseover',function(){$(this).addClass('hover');}).bind('mouseout',function(){$(this).removeClass('hover');}).bind('click',function(){$('#'+select_menu).removeClass('selected');$('#'+select_menu+'_content').hide();$(this).addClass('selected');$('#menu_001_content').show();select_menu='menu_001';});$('#menu_002').bind('mouseover',function(){$(this).addClass('hover');}).bind('mouseout',function(){$(this).removeClass('hover');}).bind('click',function(){$('#'+select_menu).removeClass('selected');$('#'+select_menu+'_content').hide();$(this).addClass('selected');$('#menu_002_content').show();select_menu='menu_002';});$('#menu_003').bind('mouseover',function(){$(this).addClass('hover');}).bind('mouseout',function(){$(this).removeClass('hover');}).bind('click',function(){$('#'+select_menu).removeClass('selected');$('#'+select_menu+'_content').hide();$(this).addClass('selected');$('#menu_003_content').show();select_menu='menu_003';});$('#menu_004').bind('mouseover',function(){$(this).addClass('hover');}).bind('mouseout',function(){$(this).removeClass('hover');}).bind('click',function(){$('#'+select_menu).removeClass('selected');$('#'+select_menu+'_content').hide();$(this).addClass('selected');$('#menu_004_content').show();select_menu='menu_004';});$('#menu_005').bind('mouseover',function(){$(this).addClass('hover');}).bind('mouseout',function(){$(this).removeClass('hover');}).bind('click',function(){$('#'+select_menu).removeClass('selected');$('#'+select_menu+'_content').hide();$(this).addClass('selected');$('#menu_005_content').show();select_menu='menu_005';});$('#regxp_submit_button').bind('click',function(){var regxp_mode=$('#regex_mode_content').val();var regxp_content=$('#regxp_text_content').val();if(regxp_mode==''){alert('请填写匹配模式!');$('#regex_mode_content').focus();return false;}
if(regxp_content==''){alert('请填写匹配内容!');$('#regxp_text_content').focus();return false;}
$.post('ajax/ajax_regxp.php',{'mode':regxp_mode,'content':regxp_content},function(data){$('#regxp_message_result').html(data);});});$('#create_mode_button').bind('click',function(){if(confirm('你确认要创建全部的Model文件?')){$.post('ajax/ajax_model.php',{},function(data){alert(data);});}
else{return false;}});$('#create_mode_each_button').bind('click',function(){var model_name=$('#mode_name').val();if(model_name==''){alert('请填写所要生成的Model文件名称!');$('#mode_name').focus();return false;}
if(confirm('你确认要创建'+model_name+'的Model文件?')){$.post('ajax/ajax_model_single.php',{'table_name':model_name},function(data){alert(data);});}
else{return false;}});$('#create_controller_button').bind('click',function(){var controller_name=$('#controller_name').val();if(controller_name==''){alert('请填写要生成的Controller的名称!');$('#controller_name').focus();return false;}
if(confirm('你确认要创建'+controller_name+'的Controller文件?')){$.post('ajax/ajax_controller.php',{'controller_name':controller_name},function(data){alert(data);});}
else{return false;}});$('#create_widget_button').bind('click',function(){var widget_name=$('#widget_name').val();if(widget_name==''){alert('请填写要生成的Widget的名称!');$('#widget_name').focus();return false;}
if(confirm('你确认要创建'+widget_name+'的Widget文件?')){$.post('ajax/ajax_widget.php',{'widget_name':widget_name},function(data){alert(data);});}
else{return false;}});$('#clear_mode_button').bind('click',function(){if(confirm('你确认要清除全部MODEL缓存文件?')){$.post('ajax/ajax_clear_mode_cache.php',{},function(data){alert(data);});}
else{return false;}});$('#clear_template_button').bind('click',function(){if(confirm('你确认要清除全部Template缓存文件?')){$.post('ajax/ajax_clear_template_cache.php',{},function(data){alert(data);});}
else{return false;}});$('#clear_data_button').bind('click',function(){if(confirm('你确认要清除全部数据缓存文件?')){$.post('ajax/ajax_clear_data_cache.php',{},function(data){alert(data);});}
else{return false;}});$('#create_config_button').bind('click',function(){var server_name=$('#server_name').val();var database_name=$('#database_name').val();var user_name=$('#user_name').val();var database_code=$('#database_code').val();var database_password=$('#database_password').val();var database_prefix=$('#database_prefix').val();if(server_name==''){alert('请填写MYSQL服务器名称!');$('#server_name').focus();return false;}
if(user_name==''){alert('请填写MYSQL用户名!');$('#user_name').focus();return false;}
if(database_password==''){alert('请填写MYSQL密码!');$('#database_password').focus();return false;}
if(database_name==''){alert('请填写MYSQL数据库名称!');$('#database_name').focus();return false;}
if(database_code==''){alert('请填写MYSQL数据库编码!');$('#database_code').focus();return false;}
if(confirm('你确认要创建Config配置文件?')){$.post('ajax/ajax_create_config.php',{'server_name':server_name,'user_name':user_name,'password':database_password,'database':database_name,'data_encode':database_code,'prefix':database_prefix},function(data){alert(data);});}
else{return false;}});$('#strlen_button').bind('click',function(){var str_content=$('#str_name').val();if(str_content==''){alert('请填写字符串内容!');$('#str_name').focus();return false;}
$.post('ajax/ajax_strlen.php',{'str_name':str_content},function(data){$('#strlen_result').text(data);});});$('#create_dir_button').bind('click',function(){if(confirm('你确认要生成系统目录吗?')){$.post('ajax/ajax_create_dir.php',{},function(data){alert(data);});}
else{return false;}});});
</script>
<style type="text/css">
<!--
body{font-family:Verdana,Geneva,sans-serif; font-size:12px; line-height:20px; color:#000; background-color:#FFF; margin:0px; padding:0px; text-align:center}
.total{padding:0px; height:560px; width:960px; margin-top:60px; margin-right:auto; margin-bottom:0px; margin-left:auto; border:1px solid #333; text-align:left}
.total .menu{margin:0px; padding:0px; height:30px; width:960px; border-top-style:none; border-right-style:none; border-bottom-style:none; border-left-style:none}
.total .menu ul{margin:0px; padding:0px; border-top-style:none; border-right-style:none; border-bottom-style:none; border-left-style:none; list-style-type:none}
.total .menu ul li{float:left; height:30px; width:150px; margin:0px; padding:0px; border-top-style:none; border-right-style:solid; border-bottom-style:solid; border-left-style:none; border-right-width:1px; border-bottom-width:1px; border-right-color:#333; border-bottom-color:#333; text-align:center; font-size:14px; line-height:30px; color:#C00; background-color:#CCC}
.total .clear_bank{margin:0px; padding:0px; height:0px; width:0px; clear:both; display:none}
.total .menu ul .hover{color:#FFF; background-color:#C00; cursor:pointer}
.total .menu ul .selected{color:#000; background-color:#FFF; border-bottom-style:none}
.total .content{padding:0px; height:470px; width:900px; background-color:#FFF; border-top-style:none; border-right-style:none; border-bottom-style:none; border-left-style:none; margin:30px; display:none}
.total #menu_001_content .message{margin:0px; padding:10px; height:220px; width:878px; border:1px solid #666; font-size:14px; line-height:24px}
.total #menu_001_content .message .legend{background-color:#FFF; position:relative; top:-24px; padding:5px; font-size:14px; font-weight:bold; color:#333}
.total #menu_001_content .regxp_mode{padding:10px; height:50px; width:878px; margin-top:20px; margin-right:0px; margin-bottom:0px; margin-left:0px; border:1px solid #666}
.total #menu_001_content .regxp_mode .legend{font-size:14px; font-weight:bold; color:#333; background-color:#FFF; padding:5px; top:-20px; position:relative}
.total #menu_001_content .regxp_mode #regex_mode_content{height:20px; width:240px; border:1px solid #666; font-size:14px; line-height:20px; color:#000}
.total #menu_001_content .regxp_mode #regxp_text_content{font-size:14px; line-height:20px; color:#000; height:60px; width:600px; border:1px solid #666; float:left}
.total #menu_001_content .regxp_mode #regxp_submit_button{height:60px; width:60px; border:1px solid #666; float:left; margin-left:20px; font-size:16px; line-height:60px; color:#333; font-weight:bold; cursor:pointer}
.total #menu_002_content .regxp_mode{padding:10px; height:50px; width:878px; margin-top:50px; margin-right:0px; margin-bottom:0px; margin-left:0px; border:1px solid #666}
.total #menu_002_content .regxp_mode .legend{font-size:14px; font-weight:bold; color:#333; background-color:#FFF; padding:5px; top:-20px; position:relative}
.total #menu_002_content .regxp_mode #create_mode_button{font-size:14px; line-height:24px; height:24px; width:120px; border:1px solid #666; margin-left:720px; color:#333; font-weight:bold; cursor:pointer}
.total #menu_002_content .regxp_mode #mode_name{font-size:14px; line-height:20px; color:#000; border:1px solid #666; height:20px; width:240px; float:left}
.total #menu_002_content .regxp_mode #create_mode_each_button{font-size:14px; line-height:24px; height:24px; width:90px; color:#333; border:1px solid #666; float:left; font-weight:bold; margin-left:10px; cursor:pointer}
.total #menu_003_content .regxp_mode{padding:10px; height:50px; width:878px; margin-top:50px; margin-right:0px; margin-bottom:0px; margin-left:0px; border:1px solid #666}
.total #menu_003_content .regxp_mode .legend{font-size:14px; font-weight:bold; color:#333; background-color:#FFF; padding:5px; top:-20px; position:relative}
.total #menu_003_content .regxp_mode #create_mode_button{font-size:14px; line-height:24px; height:24px; width:120px; border:1px solid #666; margin-left:720px; color:#333; font-weight:bold; cursor:pointer}
.total #menu_003_content .regxp_mode #controller_name{font-size:14px; line-height:20px; color:#000; border:1px solid #666; height:20px; width:240px; float:left}
.total #menu_003_content .regxp_mode #create_controller_button{font-size:14px; line-height:24px; height:24px; width:120px; color:#333; border:1px solid #666; float:left; font-weight:bold; margin-left:10px; cursor:pointer}
.total #menu_003_content .regxp_mode #widget_name{font-size:14px; line-height:20px; color:#000; border:1px solid #666; height:20px; width:240px; float:left}
.total #menu_003_content .regxp_mode #create_widget_button{font-size:14px; line-height:24px; height:24px; width:120px; color:#333; border:1px solid #666; float:left; font-weight:bold; margin-left:10px; cursor:pointer}
.total #menu_004_content .regxp_mode{padding:10px; height:50px; width:878px; margin-top:50px; margin-right:0px; margin-bottom:0px; margin-left:0px; border:1px solid #666}
.total #menu_004_content .regxp_mode .legend{font-size:14px; font-weight:bold; color:#333; background-color:#FFF; padding:5px; top:-20px; position:relative}
.total #menu_004_content .regxp_mode .button{font-size:14px; line-height:24px; height:24px; width:140px; border:1px solid #666; margin-left:700px; color:#333; font-weight:bold; cursor:pointer}
.total #menu_005_content .regxp_mode{padding:10px; height:50px; width:878px; margin-top:50px; margin-right:0px; margin-bottom:0px; margin-left:0px; border:1px solid #666}
.total #menu_005_content .regxp_mode .legend{font-size:14px; font-weight:bold; color:#333; background-color:#FFF; padding:5px; top:-20px; position:relative}
.total #menu_005_content .regxp_mode table tr td .data_input_box{font-size:14px; line-height:20px; color:#000; height:20px; width:150px; border:1px solid #666}
.total #menu_005_content .regxp_mode table tr td #create_config_button{height:24px; width:140px; font-size:14px; line-height:24px; font-weight:bold; color:#333; border:1px solid #666; cursor:pointer}
.total #menu_005_content .regxp_mode #str_name{font-size:14px; line-height:20px; color:#000; height:20px; width:240px; border:1px solid #666; float:left}
.total #menu_005_content .regxp_mode #strlen_button{font-size:14px; line-height:24px; font-weight:bold; height:24px; width:60px; border:1px solid #666; margin-left:10px; float:left; cursor:pointer}
.total #menu_005_content .regxp_mode #strlen_result{font-size:14px; line-height:20px; color:#C00; font-weight:bold; height:20px; width:520px; margin-left:20px; float:left; border-top-style:none; border-right-style:none; border-bottom-style:none; border-left-style:none}
.total #menu_005_content .regxp_mode #create_dir_button{font-size:14px; line-height:24px; height:24px; width:120px; border:1px solid #666; margin-left:720px; color:#333; font-weight:bold; cursor:pointer}
-->
</style></head>

<body>
<div class="total">

<div class="menu">
<ul>
<li id="menu_001">正则表达式验证</li>
<li id="menu_002">Model文件创建</li>
<li id="menu_003">Controller文件创建</li>
<li id="menu_004">缓存文件清理</li>
<li id="menu_005">其它</li>
<li style="width:205px; background-color:#F2F2F2; border-right:none;"></li>
</ul>
</div>
<div class="clear_bank"></div>
<!-- 正则表达式 -->
<div class="content" id="menu_001_content">
<div class="message">
<span class="legend">信息提示:</span>
<div id="regxp_message_result"></div>
</div>

<div class="regxp_mode">
<span class="legend">匹配模式:</span><br />
<input type="text" name="mode_content"  id="regex_mode_content"/>
</div>

<div class="regxp_mode" style="height:95px;">
<span class="legend">匹配内容:</span><br />
<input type="text" name="regxt_content" id="regxp_text_content" />
<input type="button" name="submit"  value="提交" id="regxp_submit_button"/>
<div class="clear_bank"></div>
</div>
</div>
<!-- /正则表达式 -->

<!-- Model文件创建 -->
<div class="content" id="menu_002_content">
<div class="regxp_mode">
<span class="legend">创建全部MODEL:</span><br />
<input type="button" name="mode_content"  value="创建全部Model" id="create_mode_button"/>
</div>

<div class="regxp_mode" style="height:60px;">
<span class="legend">创建MODEL:</span><br />
<input type="text" name="mode_content"  id="mode_name"/>
<input type="button" name="mode_content"  value="创建Model" id="create_mode_each_button"/>
<div class="clear_bank"></div>
</div>
</div>
<!-- /Model文件创建 -->

<!-- Controller文件创建 -->
<div class="content" id="menu_003_content">
<div class="regxp_mode" style="height:60px;">
<span class="legend">创建Controller:</span><br />
<input type="text" name="mode_content"  id="controller_name"/>
<input type="button" name="mode_content"  value="创建Controller" id="create_controller_button"/>
<div class="clear_bank"></div>
</div>
<div class="regxp_mode" style="height:60px;">
<span class="legend">创建Widget:</span><br />
<input type="text" name="mode_content"  id="widget_name"/>
<input type="button" name="mode_content"  value="创建Widget" id="create_widget_button"/>
<div class="clear_bank"></div>
</div>
</div>
<!-- /Controller文件创建 -->

<!-- 缓存文件清理 -->
<div class="content" id="menu_004_content">
<div class="regxp_mode">
<span class="legend">清除全部MODEL缓存:</span><br />
<input type="button" name="mode_content"  value="清除全部MODEL缓存" class="button" id="clear_mode_button"/>
</div>

<div class="regxp_mode">
<span class="legend">清除全部页面缓存:</span><br />
<input type="button" name="mode_content"  value="清除全部模板缓存" class="button" id="clear_template_button"/>
</div>

<div class="regxp_mode">
<span class="legend">清除全部数据缓存:</span><br />
<input type="button" name="mode_content"  value="清除全部数据缓存" class="button" id="clear_data_button"/>
</div>
</div>
<!-- /缓存文件清理 -->

<!-- 其它 -->
<div class="content" id="menu_005_content">
<div class="regxp_mode" style="height:auto;">
<span class="legend">生成Config文件:</span><br />
<table width="640" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="120" height="30" align="center">服务器名</td>
    <td width="200" align="left"><input  type="text" name="server_name" class="data_input_box" id="server_name"/></td>
    <td width="120" align="center">数据库名称</td>
    <td width="200" align="left"><input  type="text" name="server_name4" class="data_input_box" id="database_name"/></td>
  </tr>
  <tr>
    <td height="30" align="center">用户名：</td>
    <td align="left"><input  type="text" name="server_name2" class="data_input_box" id="user_name"/></td>
    <td align="center">数据库编码</td>
    <td align="left"><input  type="text" name="server_name5" class="data_input_box" id="database_code"/></td>
  </tr>
  <tr>
    <td height="30" align="center">密 码：</td>
    <td align="left"><input  type="password" name="server_name3" class="data_input_box" id="database_password"/></td>
    <td align="center">数据前缀</td>
    <td align="left"><input  type="text" name="server_name6" class="data_input_box" id="database_prefix"/></td>
  </tr>
  <tr>
    <td height="50" colspan="4" align="center"><input type="button" name="create_config" value="生成Config文件" id="create_config_button"/></td>
  </tr>
</table>
</div>

<div class="regxp_mode" style="height:60px;">
<span class="legend">计算字符串长度:</span><br />
<input type="text" name="mode_content"  id="str_name"/>
<input type="button" name="mode_content"  value="计算" id="strlen_button"/>
<div id="strlen_result"></div>
<div class="clear_bank"></div>
</div>

<div class="regxp_mode">
<span class="legend">生成目录</span><br />
<input type="button" name="mode_content"  value="生成目录" id="create_dir_button"/>
</div>
</div>
<!-- /其它 -->
</div>
</body>
</html>
<?php
}
?>